<?php
$smarty->configLoad($lang.'/home.module.php'); 
$language = parse_ini_file($lang.'/breadcrumb.module.php', true);
$breadcrumb = $language['dashboard'];
/*
 * Load Characters Class & data
 */
$chars = new character;
$online_players		= $chars->getChars(1);
$offline_players	= $chars->getChars(2);
$all_players		= $chars->getChars();

$smarty->assign('online_players', $online_players);
$smarty->assign('offline_players', $offline_players);
$smarty->assign('all_players', $all_players);
/*
 * Load User Class & data
 */
$user = new user;
$allUsers			= $user->allAccounts();
$activated			= $user->allAccounts(1);
$banned				= $user->allAccounts(0);

$smarty->assign('all_users', $allUsers);
$smarty->assign('activated', $activated);
$smarty->assign('banned', $banned);
/*
 * Gameserver status
 */
$gameserver = $main->serverCheck($ip_server, $port_gameserver);
$smarty->assign('gameserver', $gameserver);
/*
 * Loginserver status
 */
$loginserver = $main->serverCheck($ip_server, $port_loginserver);
$smarty->assign('loginserver', $loginserver);
/*
 * Get Donators
 */
$value = '';
$sql = 'SELECT * FROM '.DB_CMS.'.module_donate ORDER BY id DESC LIMIT 6';
$dbh = $connection->prepare($sql);
$dbh->execute();
$i = 0;
foreach($dbh->fetchAll(PDO::FETCH_ASSOC) as $row) {
    $value[] = $row;
    $value[$i]['username'] = $user->getName($row['userID']);
    $value[$i]['adminname'] = $user->getName($row['admin']);
    $i++;
}
$smarty->assign('value', $value);
/*
 * Get GM Log
 */
$gmvalue = '';
$sql = 'SELECT * FROM '.DB_CMS.'.log_action ORDER BY id DESC LIMIT 6';
$dbh = $connection->prepare($sql);
$dbh->execute();
$i = 0;
foreach($dbh->fetchAll(PDO::FETCH_ASSOC) as $row) {
    $gmvalue[] = $row;
    $gmvalue[$i]['username'] = $user->getName($row['userID']);
    $i++;
}
$smarty->assign('gmvalue', $gmvalue);
$template = 'home/index.tpl';

?>
